<script setup>
import { ref } from 'vue'
import { 
  Document,
  ChatDotRound,
  UserFilled,
  Calendar,
  User,
  HomeFilled,
  Setting
} from '@element-plus/icons-vue'
import { useRouter } from 'vue-router'

const router = useRouter()
const props = defineProps({
  isCollapse: Boolean
})

const handleSelect = (key) => {
  router.push(key)
}
</script>

<template>
  <el-aside :width="isCollapse ? '64px' : '240px'" class="aside-container">
    <div class="logo-container">
      <img src="/7.svg" class="logo" alt="logo" />
      <span v-show="!isCollapse">小王管理系统模板</span>
    </div>
    <el-menu
      :collapse="isCollapse"
      :default-active="$route.path"
      class="el-menu-vertical"
      @select="handleSelect"
      background-color="transparent"
    >
      <el-menu-item index="/">
        <el-icon><HomeFilled /></el-icon>
        <span>工作台</span>
      </el-menu-item>
      
      <el-sub-menu index="/users">
        <template #title>
          <el-icon><Setting /></el-icon>
          <span>系统管理</span>
        </template>
        <el-menu-item index="/users/list">
          <el-icon><User /></el-icon>
          <span>用户管理</span>
        </el-menu-item>
      </el-sub-menu>
      
      <el-sub-menu index="/students">
        <template #title>
          <el-icon><UserFilled /></el-icon>
          <span>学生管理</span>
        </template>
        <el-menu-item index="/students/list">
          <el-icon><Document /></el-icon>
          <span>学生列表</span>
        </el-menu-item>
        <el-menu-item index="/students/courses">
          <el-icon><ChatDotRound /></el-icon>
          <span>课程分配</span>
        </el-menu-item>
        <el-menu-item index="/students/expiring">
          <el-icon><Calendar /></el-icon>
          <span>到期学生</span>
        </el-menu-item>
      </el-sub-menu>
    </el-menu>
  </el-aside>
</template>

<style scoped>
.aside-container {
  height: 100vh;
  transition: width 0.3s;
  border-right: 1px solid var(--el-border-color-light);
  background-color: var(--el-bg-color);
}

.logo-container {
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 16px;
  overflow: hidden;
  /* border-bottom: 1px solid var(--el-border-color-light); */
}

.logo-container .logo {
  height: 32px;
  margin-right: 12px;
}

.logo-container span {
  font-size: 18px;
  font-weight: bold;
  white-space: nowrap;
  color: var(--el-text-color-primary);
}

.el-menu-vertical {
  height: calc(100% - 56px);
  border-right: none;
}

.el-menu-vertical:not(.el-menu--collapse) {
  width: 230px;
}
</style>
